
requirejs.config({
    baseUrl: '../www',
    paths: {
        app: 'js/app',
        makepy:'js/makepy',
        html2canvas:'js/html2canvas',
        ionic: u9.toU9URL('lib/ionic/js/ionic.bundle'),
        chart: u9.toU9URL('lib/echarts/echarts'),
        microsoftAjax: u9.toU9URL('lib/MicrosoftAjax')
    }
});

// Start the main app logic.
requirejs(['app', 'makepy','microsoftAjax','html2canvas'], function () {

    u9.callSVAlone = function (jsonData) {
        var svFullName = jsonData['name'],
            params = jsonData['params'],
            address = u9.getConnectSetting().address,
            port = u9.getConnectSetting().port,
            url = 'http://' + address + ':' + port + '/svc_script/' + '?n=' + svFullName + '&p=null';
        var onSuccess = function (data) {
        };
        var onFailure = function (data) {
        };
        return require([url], function (bpObj) {
            params.unshift({
                EntCode: u9.getLoginData().EntCode,
                OrgCode: u9.getLoginData().OrgCode,
                UserCode: u9.getLoginData().UserCode,
                CultureName: 'zh-CN'
            });
            if (jsonData['onSuccess']) {
                params.push(jsonData['onSuccess']);
            } else {
                params.push(onSuccess);
            }
            if (jsonData['onFailure']) {
                params.push(jsonData['onFailure']);
            } else {
                params.push(onFailure);
            }

            var svcProxy = 'http://' + address + ':' + port + '/u9_gateway/RestServices/' + svFullName + '.svc';
            try {
                bpObj.set_path(svcProxy);
                return bpObj.Do.apply(bpObj, params);
            } catch (e) {
                return jsonData.onFailure(e);
            }
        });
    };

});